<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Init Model
 *
 */
class Admin_settings_model extends CI_Model {

    /**
     * User data, stored for embeded methods
     *
     * @access 	private
     * @var 	array
     */
    var $settings = array();

    /**
     * Constructor
     *
     * @uses 	get_settings
     * @return 	void
     */
    function __construct() {
        parent::__construct();
        log_message('debug', 'Init Model Initialized');
        
    }

    /**
     * Get Settings
     *
     * Get all the auto loaded settings from the db.
     *
     * @return	array
     */

    function get_setting_info($name) {
        
            $sql = "Select * from web_settings where variable='$name'";
            $query = $this->db->query($sql);
            if ($query->num_rows() > 0) {
                $row = $query->row();
                return $row;
            }
            return FALSE;
       
    }

    function get_web_settings($id=0) {
    	if ($id) {
    		$sql = "select * from web_settings  where id=$id order by id";
    		$query = $this->db->query($sql);
    		$result = $query->row();
    		return $result;
    	}
    }
    
    function update_settings($value=NULL,$id=0) {
    	$sql = "update web_settings set value='$value' where id=$id";
    	$this->db->query($sql);
    }

    function get_setting($name) {
    	if (!empty($this->settings[$name])) {
    		return $this->settings[$name];
    	} else {
    		$this->db->select('value')->from('web_configuration')->where('variable', $name);
    		$query = $this->db->get();
    		if ($query->num_rows() > 0) {
    			$row = $query->row();
    			return $row->value;
    		}
    		return FALSE;
    	}
    }
    
 function get_socials($id) {

        $sql = "select * from social where id=$id";
        $query = $this->db->query($sql);
        $result = $query->row();
        return $result;
    }
    
   /* function get_configuration($id) {
    
    	$sql = "select * from web_settings where id=$id";
    	$query = $this->db->query($sql);
    	$result = $query->row();
    	return $result;
    }
    */
    
    function getWebsettings($id) {
    
    	$sql = "select * from web_settings where id=$id";
    	$query = $this->db->query($sql);
    	$result = $query->row();
    	return $result;
    }
    
    

    
}

?>